package com.s.core.root.data;

import com.c1.client.pan.PanConf;
import com.s.core.root.D;

import java.math.BigDecimal;

public class _Point extends _BasePoint {
    public _Point(_BasePic pic, D d, int total, int recentIndex) {
        super(pic, d, total, recentIndex);
    }

    @Override
    public int posValue() {
        return d.getPos1();
    }

    @Override
    public BigDecimal volValue() {
        return new BigDecimal(d.getVol());
    }

    public boolean isZt() {
        checkTp();
        return d.isZt();
    }

    public boolean isWeakZt() {
        checkTp();
        return d.isWeakZt();
    }

    public Integer syValue() {
        checkTp();
        return d.syValue();
    }

    public double rate() {
        if (isZt()) {
            return 0.001;
        }
        return super.rate();
    }

    @Override
    public InfoAndStyle yInfoValue() {
        return null;
    }

    @Override
    public InfoAndStyle xInfoValue() {
        if (recentIndex < 4 && !isZt()) {
            Integer syValue = syValue();
            if (syValue == null) {
                return null;
            }
            return new InfoAndStyle(String.valueOf(syValue), PanConf.me().xInfoStyle);
        }
        return null;
    }

    @Override
    protected PanConf.PosStyle posStyleValue() {
        if (isZt()) {
            return PanConf.me().ztPosStyle;
        } else if (isWeakZt()) {
            return PanConf.me().weakZtPosStyle;
        } else {
            return PanConf.me().commonPosStyle;
        }
    }

    @Override
    protected PanConf.CjlStyle cjlStyleValue() {
        return PanConf.me().cjlStyle;
    }
}
